<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>我的订单</title>
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="stylesheet" href="../css/mui.min.css">
    <script src="../js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="../js/cookieutil.js" type="text/javascript" charset="utf-8"></script>
    <script src="../js/mui.min.js"></script>
    <script src="../js/mui.pullToRefresh.js"></script>
    <script src="../js/mui.pullToRefresh.material.js"></script>
<style>
    .mui-content .mui-fullscreen {
        top: 44px;
        height: auto;
    }
    *{touch-action: none;}
</style>
</head>

<body>
<div class="headpage"></div>  
<div class="mui-content">
    <div id="slider" class="mui-slider mui-fullscreen" style="height: 46px!important;position:fixed;">
        <div id="sliderSegmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted" style="border-top:1px solid #000;background:#ffffff!important;">
            <div class="mui-scroll">
                <button class="mui-control-item mui-active mui-btn mui-btn-block" onclick="getdata(this.id)" id="0">
                    待申请
                </button>
                <button class="mui-control-item mui-btn mui-btn-block" onclick="getdata(this.id)" id="1">
                    待付款
                </button>
                <button class="mui-control-item mui-btn mui-btn-block" onclick="getdata(this.id)" id="2">
                    已付款
                </button>

            </div>
        </div>
    </div>
    <div style="width: 100%;margin-top: 70px;!important;height: 100%;" >
        <div class="mui-card" style="bottom: 50px;">
            <form class="mui-input-group" id="codehtml">

            </form>
        </div>

    </div>




    <button type="button" class="mui-btn mui-btn-primary"  id="bottomPopover"  style="width: 80%;height: 35px;float: left;margin-left: 10%;margin-top: 20px;position:fixed; bottom:9%;">提现</button>


</div>
<div class="footerpage">
</div>
<div id="popover" class="mui-popover" style="width: 98%;margin-left: 1%;margin-right: 1%;">
    <form class="mui-input-group">
        <div class="mui-input-row ">
            <label>开户名称:</label>
            <input type="text" class=" mui-input-clear" placeholder="" id="username">
        </div>
        <div class="mui-input-row ">
            <label>开户银行:</label>
            <input type="text" class=" mui-input-clear" placeholder="" id="kaihuhang">
        </div>
        <div class="mui-input-row ">
            <label>银行卡号:</label>
            <input type="text" class=" mui-input-clear" placeholder="" id="yinhangka">
        </div>

    </form>
    <button type="button" class="mui-btn mui-btn-primary"  onclick="save()" style="width: 100%;height: 35px;">确定</button>
</div>
<script src="../js/mui.min.js"></script>
<script src="../js/mui.pullToRefresh.js"></script>
<script src="../js/mui.pullToRefresh.material.js"></script>
<script>
    var typedata=0;
    var pagindex=0;
    var pagesize=20;
    $(".headpage").load("head.html");
    $(".footerpage").load("footer.html");
    var remake="";
    var moneytx=0;

    var isOver = false;//是否加载完
    var  userid=getCookie('userid');
    function setdata(obj)
    {//状态:0=客单,1=协助,2=押金，3=提现
        if (obj==0)
        {
            return"客单";
        }
        if (obj==1)
        {
            return"协助";
        }
        if (obj==3)
        {
            return"提现";
        }
    }
    var getdata = function(obj) {
        if (obj ==0) {
            $("#bottomPopover").show();//表示display:block,
        }
        else {
            $("#bottomPopover").hide();//表示display:block,
        }

            if (typedata!=obj){
                typedata=obj
                pagindex=0;
                pagesize=20;
            }
        var data = {
            userid: userid,
            status:typedata,
            pageindex:pagindex,
            pagesize:pagesize
    }
        //请求后台数据
        mui.post('/Salary/findByupopenid', data, function (info) {
            var x = document.getElementById("codehtml");
            console.log(info);
            var str='';
            var datas = info.object;

            if(datas.length == 0){//当datas.length为0时，表示没有数据了
                mui.toast('没有查询到数据...');
                x.innerHTML="";
            }else{
                if(datas.length < pagesize){
                    isOver = true;
                }
                var str = "";
                for (var i = 0; i < datas.length; i++) {
                    cold = datas[i];
                    if (cold['status']==0)
                    {
                        str+= ' <div class="mui-input-row mui-checkbox mui-left" style="height: 50px;">';
                        str+=  '<label>'+"来源:"+setdata(cold['type'])+"&nbsp;&nbsp;&nbsp;&nbsp;金额"+cold['money']+"元"+"<br>时间："+formattime(cold['createtime'])+'</label>';
                        str+='<input name="checkbox" value="'+cold['money']+'" type="checkbox"  id="'+cold['id']+'"/>';
                        str+=' </div>';


                    }
                    if (cold['status']==1||cold['status']==2)
                    {
                        str+= ' <div class="mui-input-row mui-checkbox mui-left" style="height: 50px;">';
                        str+=  '<label>'+"来源:"+setdata(cold['type'])+"&nbsp;&nbsp;&nbsp;&nbsp;金额:"+cold['money']+"元"+"<br>时间："+formattime(cold['createtime'])+'</label>';
                        str+=' </div>';

                    }
                }
                if(isOver == false){
                    pagindex++;
                    pagesize=pagindex*20;
                }
                x.innerHTML=str;
            }
        });
    }




    document.getElementById("bottomPopover").addEventListener("tap", function() {
        var ele = document.getElementsByName("checkbox");
        remake="";moneytx=0;
        for (var i = 0; i < ele.length; i++) {
            if(ele[i].checked) {
                if (remake == "" || remake == undefined || remake == null) {
                    remake = ele[i].id;
                } else {
                    remake = remake + "," + ele[i].id;
                }
                if (moneytx == 0) {
                    var cc = new Number(ele[i].value)
                    moneytx = cc;
                } else {
                    var cc = new Number(ele[i].value)
                    moneytx = moneytx + cc;
                }

            }
        }
        if ((remake == "" || remake == undefined || remake == null)||moneytx == "" || moneytx == undefined || moneytx == null)
        {
            mui.toast("请选择需要提现的记录！");
            return;
        }
        mui("#popover").popover('toggle', document.getElementById("div"));
    })

function save() {
    var kaihuhang = $("#kaihuhang").val();
    var yinhangka = $("#yinhangka").val();
    var username = $("#username").val();
    if (kaihuhang == "" || kaihuhang == undefined) {
        mui.toast('请输入你的开户行');
        return;
    }
    if (yinhangka == "" || yinhangka == undefined) {
        mui.toast('请输入你的银行卡号！');
        return;
    }
    if (username == "" || username == undefined) {
        mui.toast('请输入你的姓名！');
        return;
    }

    mui.post('/Salary/insertTx',
        {
            userid: userid,
            money: moneytx,
            kaihuhang: kaihuhang,
            yinhangka: yinhangka,
            username:username,
            remake: remake
        },
        function (data) {
            console.log(data);
            if (data.code) {
                mui.toast('资料提交成功请你等待处理！');
                window.location.reload();
            }
            else {
                mui.toast(data.msg);
            }
        }, 'json'
    )
};

    /**
      * 上拉加载
      */
    function pullupRefresh() {
        setTimeout(function () {
            mui('#pullrefresh').pullRefresh().endPullupToRefresh((isOver)); //参数为true代表没有更多数据了。
            getData();//ajax
        }, 500);
    }
    
    (function($) {
        mui.init()

        mui('body').on('div','button',function(){document.onclick=this.onclick;});
        getdata(0);
    })(mui);





</script>
</body>

</html>